package com.beans;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

/*
* 使用构造方法实现注入bean
* */
@Controller
public class UserController2 {
    private UserService userService;

//  @Resource 不支持
    @Autowired// 注解，还是@Autowired
    public UserController2(UserService userService){
        // 传统写法： userService = new UserService();
        this.userService = userService;
    }

    public UserController2(UserService userService,int x){
        this.userService = userService;
    }

    public void sayHi(){
        userService.sayHi();
    }
}
